package sax;

import java.io.IOException;
import java.sql.SQLException;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.xml.sax.SAXException;

public class Test {

	private static Logger logger = Logger.getLogger(Test.class);

	static public void main(String[] args) {
		try {
			String path = null;

			PropertyConfigurator.configure("log4j.properties");
			if (args == null || args.length != 1) {
				logger.error("if you dont pass parameter db.properties "
						+ "file should be in the class path");
				path = "";
			} else {
				path = args[0];
			}
			Manager mngr = new Manager(path);
			mngr.processExportingToXML();
			mngr.processImportToDB();
			mngr.doOnExit();
		} catch (SAXException e) {
			logger.error(e);
		} catch (ParserConfigurationException e) {
			logger.error(e.initCause(e));
		} catch (IOException e) {
			logger.error(e);
		} catch (SQLException e) {
			logger.error(e);
			logger.error("SQLState: " + e.getSQLState());
			logger.error("Error Code: " + e.getErrorCode());
		}

	}

}
